[C] How I change a variable of a type to another one?
        Posted  
        
            by drigoSkalWalker
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by drigoSkalWalker
        
        
        
        Published on 2010-05-12T21:13:02Z
        Indexed on 
            2010/05/12
            21:24 UTC
        
        
        Read the original article
        Hit count: 221
        
I want to do it:
int main () {
  bla bla bla
  void *onetype;
  switch (USER_INPUT_TYPE) {
      CASE CONVERT_TO_CHAR:
          convert onetype VOID TO CHAR >>> HOW???
      CASE CONVERT_TO_INT:
          convert onetype VOID TO INT >>> HOW???
   LOT OF CASES...
   }
}
Yes, I know type casting, but type casting is a 'temporary' change... So...Is there any way to accomplish it in C?
EDIT :
Stop stop stop! Please, see, what are you doing is type casting, I KNOW THIS, you are creating another variable of the desirable type like int i = (int) onetype, I don't want this, I want something else like onetype = (int) onetype, without recreate them, without allocate another variable.
Thanks a lot guys!
© Stack Overflow or respective owner